import sys
sys.path.append('..')

class Issue:
    targetType = "issue"
    commit = "评论"
    def __init__(self, title, url, *args):
        if len(args) == 0:
            soup = getSoup(url)
            self.no = getIssueNo(soup)
            self.title = title
            self.url = url
            self.state = getIssueState(soup)
            self.cve_id = getCVE(soup)
            self.targetId = getIssueTargetId(soup)
        else:
            self.no = args[0]
            self.title = title
            self.url = url
            self.state = args[1]
            self.cve = args[2]
            self.targetId = args[3]
    # 定义一个类方法，用于创建一个实例
    @classmethod
    def create(cls, no, title, url, state, cve, targetId):
        return cls(title, url, no, state, cve, targetId)
    @classmethod
    def getStateOfIssue(cls, url):
        soup = getSoup(url)
        return getIssueState(soup)
    def __str__(self):
         return "Issue('no':{}, 'title':{}, 'url':{}, 'state':{}, 'cve':{}, 'targetId':{})".format(self.no, self.title, self.url, self.state, self.cve, self.targetId)
 